Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: question mark for placeholder does not work #1424

Closed
wants to merge 4 commits into from

Conversation

vanvuongngo
Copy link
Contributor

@vanvuongngo vanvuongngo commented Nov 25, 2024

fix: question mark for placeholder does not work

If I follow the example with a question mark for a placeholder then this exception is thrown.

connection.execute("delete from tb_test where id=?", ['test3']);
"[object Object]" is not one of the cases of error

or this with a try-catch

error:

(new Error("[object Object] (see error.payload)", "dist.bindings.js", 157))

error.payload:

{ tag: "query-failed", val: "Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42601), message: "syntax error at end of input", detail: None, hint: None, position: Some(Original(35)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1240), routine: Some("scanner_yyerror") }) }" }

environment

  • spin: 3.0.0
  • macos
  • postgresql 17
  • target: wasm32-wasip1

Copy link
Contributor Author

@vanvuongngo vanvuongngo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add try-catch to get error informations

@itowlson
Copy link
Contributor

Thanks for flagging this! However, the page in question covers both MySQL and Postgres. The example in this PR is for MySQL, for which the question mark is correct. And we didn't want to clutter the page with MySQL and Postgres examples that were almost identical, so instead the paragraph above the sample links to a Postgres example.

I'll look at adding comments to the sample noting differences for Postgres.

@karthik2804 is it worth surfacing the error payload more visibly in this case, or is that part of the JS exception system and out of our control?

@karthik2804
Copy link
Contributor

@itowlson That error is the error generated as part of the bindings in ComponentizeJS. I think we can use try catch to make it clearer maybe but will have to take a look.

@vanvuongngo
Copy link
Contributor Author

Ah good catch and I did not realize that it was for MySql only. It took me awhile to figure out a solution w/o any documentation for postgresql.

@itowlson
Copy link
Contributor

@vanvuongngo No worries. I'm proposing #1426 as a fix instead if you want to weigh in on that. And we appreciate you flagging that this was confusing!

@vanvuongngo vanvuongngo deleted the vvn-patch-rdbms branch November 27, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants